{include file="header"}
<div style="padding: 20px;" class="adminmyucms">
<form class="layui-form" action="">
<table class="layui-table">
  <colgroup>
    <col width="100">
    <col width="500">
    <col width="100">
    <col>
  </colgroup>
  <thead>
    <tr>
      <th>用户</th>
      <th>内容</th>
      <th>操作</th>
    </tr> 
  </thead>
  <tbody>
    <tr>
      <td><input type="number" name="userid" value=""  placeholder="指定用户uid 0是系统消息" autocomplete="off" lay-verify="required" class="layui-input"></td>
      <td><textarea name="content" placeholder="请输入内容" class="layui-textarea"></textarea></td>
      <td><button class="layui-btn layui-btn-warm" lay-submit lay-filter="set-add">添加消息</button></td>
    </tr>
  </tbody>
</table>
</form>
<hr style="padding:10px; background-color: #fff">
<table class="layui-table biaoge" lay-size="lg">
  <colgroup>
    <col width="100">
    <col width="500">
    <col width="100">
    <col width="100">
    <col width="100">
    <col>
  </colgroup>
  <thead>
    <tr>
      <th>用户</th>
      <th>内容</th>
      <th>状态</th>
      <th>时间</th>
      <th>操作</th>
    </tr> 
  </thead>
  <tbody>
{volist name=":fun_s('xiaoxi',array('model'=>0,'model'=>0,'uid'=>0),'id desc','20,false',0)" id="vo"}
    <tr>
      <td>{if condition="$vo['userid'] eq '0'"}系统消息{else /}发送给【{:fun_sc_p('member', array('userid'=>$vo['userid']), 'username')}】{/if}</td>
      <td>{:htmltext($vo['content'])}</td>
      <td>{if condition="$vo['open'] eq '1'"}未读{else /}已读{/if}</td>
      <td>{$vo.time|timeinfo}</td>
      <td> <a  member-name="确定要删除这条记录吗?" url="{:url("set/delete")}?id={$vo.id}&m=xiaoxi" lay-submit lay-filter="delete"  class="layui-btn layui-btn-danger layui-btn-sm"> <i class="layui-icon">&#xe640;</i>删除</a></td>
    </tr>
{/volist}
  </tbody>
</table>
<div class="pages">
{:fun_s('xiaoxi',array('model'=>0,'model'=>0,'uid'=>0),'id desc','20,false',0)->render()}
<div>
</div> 
<script>
layui.use('form',function(){
  var form = layui.form
  ,jq = layui.jquery;
  //添加
  form.on('submit(set-add)', function(data){
    loading = layer.load(2, {
      shade: [0.2,'#000']
    });
    var param = data.field;
    jq.post('{:url("member/insertxx")}',param,function(data){
      if(data.code == 1){
        layer.close(loading);
        layer.msg(data.msg, {icon: 1, time: 1000}, function(){
          location.reload();
        });
      }else{
        layer.close(loading);
        layer.msg(data.msg, {icon: 2, anim: 6, time: 1000});
      }
    });
    return false;
  });
})
layui.use('laydate', function(){
  var laydate = layui.laydate;
  laydate.render({
    elem: '#time'
  });
});
</script>
{include file="footer"}